import os
from typing import List
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    """Application settings"""
    
    # Server settings
    HOST: str = "0.0.0.0"
    PORT: int = 8001
    DEBUG: bool = True
    
    # OCR settings
    OCR_LANGUAGE: str = "en"  # Chinese and English
    OCR_USE_ANGLE_CLS: bool = True
    OCR_USE_SPACE_CHAR: bool = True
    OCR_GPU: bool = False  # Use CPU version
    
    # Model paths - can be overridden via environment variables
    OCR_DET_MODEL_DIR: str = ""  # Use default PaddleOCR models if empty
    OCR_REC_MODEL_DIR: str = ""  # Use default PaddleOCR models if empty
    OCR_CLS_MODEL_DIR: str = ""  # Use default PaddleOCR models if empty
    
    # High accuracy model option
    OCR_USE_HIGH_ACCURACY: bool = False  # Use server models for higher accuracy
    
    # File upload settings
    MAX_FILE_SIZE: int = 10 * 1024 * 1024  # 10MB
    ALLOWED_EXTENSIONS: List[str] = ["jpg", "jpeg", "png", "bmp", "tiff", "webp"]
    
    # Logging settings
    LOG_LEVEL: str = "INFO"
    
    class Config:
        env_file = ".env"
        case_sensitive = True

# Create global settings instance
settings = Settings()